package com.ja.openchat.views;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.blankj.utilcode.util.ToastUtils;
import com.google.gson.JsonObject;
import com.ja.openchat.R;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.util.XPopupUtils;
import com.zy.openchat.core.manager.TelegramManager;
import com.zy.openchat.core.manager.TgResponse;
import com.zy.openchat.core.manager.TgResultBlock;
import com.zy.openchat.core.model.message.ChatInfo;
import com.zy.openchat.core.model.user.UserInfo;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;

import androidx.annotation.NonNull;
import me.goldze.mvvmhabit.widget.LoadingDialog;

public class BaseBottomDialog extends BottomPopupView{

    protected LoadingDialog mProgressDialog;


    public BaseBottomDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        initView();
    }

    public void initView() {
        mProgressDialog = new LoadingDialog(getContext());
        mProgressDialog.setCanceledOnTouchOutside(false);
    }

    public void showProgress() {
        if (mProgressDialog != null && !mProgressDialog.isShowing() && isShow()) {
            mProgressDialog.show();
        }
    }

    public synchronized void hideProgress() {
        if (mProgressDialog != null && mProgressDialog.isShowing() && !isDismiss()) {
            mProgressDialog.dismiss();
        }
    }

    public void showErrorTip(String error) {
        Toast toast = Toast.makeText(getContext(), error, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }
}
